import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:woniutaofang/components/ui/image_load_view.dart';
import 'package:woniutaofang/components/ui/photo_view.dart';
import 'package:woniutaofang/utils/utils.dart';

class SwiperHeroWidget extends StatelessWidget {
  final List pics;
  final String id;
  SwiperHeroWidget(this.pics, this.id);
  @override
  Widget build(BuildContext context) {
    return Swiper(
      pagination: SwiperPagination(
          builder: SwiperPagination.fraction, alignment: Alignment.bottomRight),
      autoplay: pics.length > 1,
      itemCount: pics.length,
      itemBuilder: (BuildContext context, int index) => Hero(
        tag: id,
        child: GestureDetector(
          onTap: () => {
            Navigator.push(
              context,
              CupertinoPageRoute(
                builder: (context) {
                  return PhotoViewPage(
                    title: '楼盘',
                    photos: pics,
                    heroTag: id,
                  );
                },
              ),
            )
          },
          child: ImageLoadView('${pics[index].toString()}',
              fit: BoxFit.fill, height: 200.0, width: Utils.width),
        ),
      ),
    );
  }
}
